import React, {Component} from 'react';
import Taro from "@tarojs/taro";
import {View} from '@tarojs/components'
import {platform} from '../../utils/platform-settting.service'
import {h5Wx} from "../../utils/h5.service";
import {vcmonitor} from "../../utils/tools";
import GzhAuth from "../../components/gzh-auth/gzh-auth"
import './rule.scss'

export default class Rule extends Component {
  state = {
    phone: '',
    payVersion: Number,
    min: 0,
    f: 0
  }

  async componentDidShow() {
    vcmonitor(this)
  }

  async UNSAFE_componentWillMount() {
    if (process.env.TARO_ENV === 'h5') {
      await h5Wx.getConfig()
    }
    const {min, f} = Taro.getCurrentInstance().router.params
    this.setState({
      min, f
    })
    const setting = await platform.getSetting()
    if (setting) {
      this.setState({phone: setting.platformServicePhone, payVersion: setting.payVersion})
    }
  }

  render() {
    const {payVersion, min, f} = this.state;
    return (
      <View className="rule-page-root">
        <GzhAuth/>
        <View className="page__bd">
          <View className="weui-form-preview">
            <View className="weui-form-preview__hd">
              <View className="weui-form-preview__tit">
                提现规则
              </View>
            </View>
            <View className="weui-form-preview__bd">
              <View className="weui-form-preview__item">
                <View className="weui-form-preview__label">金额限制</View>
                <View className="weui-form-preview__value">余额 >= {min} 元随时可提现</View>
              </View>
              {process.env.P_ENV !== 'kd' && <View className="weui-form-preview__item">
                <View className="weui-form-preview__label">提现方式</View>
                <View className="weui-form-preview__value">订单完成后可提现</View>
              </View>}

              {process.env.P_ENV === 'kd' && <View className="weui-form-preview__item">
                <View className="weui-form-preview__label">提现方式</View>
                <View className="weui-form-preview__value">下单后15天/部分核销可提</View>
              </View>}
              {process.env.P_ENV === 'kd' && <View className="weui-form-preview__item">
                <View className="weui-form-preview__label">提现要求</View>
                <View className="weui-form-preview__value">添加财务微信审核</View>
              </View>}

              <View className="weui-form-preview__item">
                <View className="weui-form-preview__label">单日提现限额</View>
                <View className="weui-form-preview__value">{process.env.P_ENV === 'kd' ? 200 : 5000} 元</View>
              </View>
              <View className="weui-form-preview__item">
                <View className="weui-form-preview__label">到账时间</View>
                <View className="weui-form-preview__value">1-3 个工作日内</View>
              </View>
              <View className="weui-form-preview__item">
                <View className="weui-form-preview__label">提现次数</View>
                <View className="weui-form-preview__value">当日最多 1 次</View>
              </View>

              <View className="weui-form-preview__item">
                <View className="weui-form-preview__label">提现手续费</View>
                <View className="weui-form-preview__value">{payVersion ? f + ' 元' : '无'}</View>
              </View>
              <View className="weui-form-preview__item">
                <View className="weui-form-preview__label">充值手续费</View>
                <View className="weui-form-preview__value">{payVersion ? '无' : '交易总金额的千分之六'}</View>
              </View>
            </View>
          </View>
        </View>
      </View>
    )
  }
}
